package ru.len.cafe.ejb.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import ru.len.cafe.entity.model.Dish;
import ru.len.cafe.entity.model.Employe;
import ru.len.cafe.entity.model.Serve;

/**
 * 
 * @author Stanislav Chetvertkov
 *
 */

@Stateless
public class ServeDao {
    
    @PersistenceContext(unitName="LenCafePU")
    EntityManager em;
    
    /**
     * Add Serve to the database
     * @param serve
     */
    public void createServe(Serve serve){
	em.persist(serve);
    }
    
    /**
     * Delete Serve from the database
     * @param serve
     */
    public void deleteServe(Serve serve){
	em.remove(serve);
    }
    
    /**
     * Updates existing Serve
     * @param serve
     */
    public void updateServe(Serve serve){
	em.refresh(serve);
    }
    
    /**
     * Find Serve by ID
     * @param serveId
     * @return
     */
    public Serve findServeById(int serveId){
	return ((Serve) em.find(Serve.class, serveId));
    }

}
